/**
 * 剑指 Offer 45. 把数组排成最小的数
 * https://leetcode-cn.com/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/
 */

/**
 * @param {number[]} nums
 * @return {string}
 */
function minNumber(nums) {
  nums.sort((a, b) => (`${a}${b}` > `${b}${a}` ? 1 : -1));
  return nums.join('');
}

console.log(minNumber([10, 2]) === '102');
console.log(minNumber([3, 30, 34, 5, 9]) === '3033459');
